package com.vehicle.controller;

import com.vehicle.bean.Menu;
import com.vehicle.pojo.User;
import com.vehicle.service.MenuService;
import org.apache.log4j.Logger;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
public class MenuController {
    private Logger logger=Logger.getLogger(this.getClass());
    @Autowired
    private MenuService menuService;

    @GetMapping("/indexmenus")
    public List<Menu> leftMenu(){
        Subject subject = SecurityUtils.getSubject();
        Session session = subject.getSession();
        User user=(User) session.getAttribute("USER_SESSION");
        logger.info(user);
        List<Menu> menus=  menuService.indexLeftMenu(user.getUid());

        return menus;
    }
}
